package com.dotflat.physicalevaluate.service.impl.chart;


import org.springframework.stereotype.Service;

import java.util.Map;


@Service
public class RemoteSpiderChartServiceImpl extends AbstractRemoteHighChartService {

    private static final String JSON_TEMPLATE = "{ \"infile\":{" +
            "  \"credits\": { " +
            "    \"enabled\": false" +
            "  }, " +
            "  \"chart\": {" +
            "    \"polar\": true," +
            "    \"type\": \"line\"" +
            "  }," +
            "  \"title\": {" +
            "    \"text\": \"\"," +
            "    \"x\": -80" +
            "  }," +
            "  \"pane\": {" +
            "    \"size\": \"100%\"" +
            "  }," +
            "  \"xAxis\": {" +
            "    \"categories\": [#categories]," +
            "    \"tickmarkPlacement\": \"on\"," +
            "    \"lineWidth\": 0" +
            "  }," +
            "  \"yAxis\": {" +
            "    \"gridLineInterpolation\": \"polygon\"," +
            "    \"lineWidth\": 0," +
            "    \"min\": 0" +
            "  }," +
            "  \"plotOptions\": {   " +
            "    \"line\": { " +
            "      \"dataLabels\" : { " +
            "        \"enabled\" : true " +
            "      }," +
            "      \"enableMouseTracking\": false " +
            "    } " +
            "  }," +
            "  \"legend\": {" +
            "    \"align\": \"right\"," +
            "    \"verticalAlign\": \"top\"," +
            "    \"y\": 70," +
            "    \"layout\": \"vertical\"" +
            "  }," +
            "  \"series\": [#series]" +
            "}}";





    public byte[] getRemoteEvaluateChart(Map dataMap) {

        String categories = (String)dataMap.get("categories");
        String series = (String)dataMap.get("series");

        String jsonData = JSON_TEMPLATE.replace("#categories",categories);
        jsonData = jsonData.replace("#series",series);

        System.out.println("*********************begin******************");
        System.out.println(jsonData);
        System.out.println("**********************end*******************");
        //0,0,0,0,0,0,0
        return binaryHTTPCall(chartServerURL, jsonData, "创建测评结果图表时异常");
    }



}
